package com.example.demo.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.util.StringUtils;
@Data
public class ResponseEntity<T> {

    private  Integer  code;
    private  String message;
    private  T data;
    
    public ResponseEntity(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    // 工具类 一般都有静态方法  ：success，failed
    // 200 是成功    failed 500
    public  static <T> ResponseEntity<T> success(String msg){
        return  new ResponseEntity<T>(200,msg,null);
    }

    public  static <T> ResponseEntity<T> failed(String msg){
        return  new ResponseEntity<T>(500,msg,null);
    }


}
